<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function Rich(name,age,gender){
            this.name=name;
            this.age=age;
            this.gender=gender;

        }
        // Rich.prototype.money=["card1","card2","card3"];
        // Rich.prototype.enjoy=function (){
        //     alert("enjoy");
        // }
        Rich.prototype={
            constructor:Rich,
            money:["card1","card2","card3"],
            enjoy:function(){
                alert("enjoy");
            }
        }

        var r1=new Rich("terry",20,"man")

        function Poor(name,age,gender,color){
            // this.name=name;
            // this.age=age;
            // this.gender=gender;
            Rich.call(this,name,age,gender);
            this.color=color
        }
        // Poor.prototype=Rich.prototype;
        // Rich.prototype.constructor=Poor;

        Poor.prototype=new Rich();
        Poor.prototype.constructor=Poor;

        Poor.prototype.work=function(){
            alert("快去work挣钱");
        }
        
        //如果将25行放在26行之后，则Poor的实例p1将不能用work
        var p1=new Poor("lisi",12,"female","black");
        console.log(p1);
        console.log(p1.money);
        console.log(p1.constructor);
        console.log(r1.constructor);

    </script>
</head>
<body>
    
</body>
</html>